shell: shell,
jobs: options.flag_jobs,
target: options.flag_target.as_ref().map(|t| t.as_slice()),
+ dev_deps: false,
};
ops::compile(&root, &mut opts).map(|_| None).map_err(|err| {
shell: shell,
jobs: options.flag_jobs,
target: None,
+ dev_deps: false,
},
};
shell: shell,
jobs: options.flag_jobs,
target: None,
+ dev_deps: true,
};
let err = try!(ops::run(&root, &mut compile_opts,
shell: shell,
jobs: options.flag_jobs,
target: options.flag_target.as_ref().map(|s| s.as_slice()),
+ dev_deps: true,
};
let err = try!(ops::run_tests(&root, &mut compile_opts,
pub shell: &'a mut MultiShell,
pub jobs: Option<uint>,
pub target: Option<&'a str>,
+ pub dev_deps: bool,
}
pub fn compile(manifest_path: &Path,
options: &mut CompileOptions)
-> CargoResult<ops::Compilation> {
- let CompileOptions { update, env, ref mut shell, jobs, target } = *options;
+ let CompileOptions { update, env, ref mut shell, jobs, target,
+ dev_deps } = *options;
let target = target.map(|s| s.to_string());
log!(4, "compile; manifest-path={}", manifest_path.display());
let mut config = try!(Config::new(*shell, jobs, target.clone()));
let mut registry = PackageRegistry::new(&mut config);
+ let dependencies = package.get_dependencies().iter().filter(|dep| {
+ dep.is_transitive() || dev_deps
+ }).map(|d| d.clone()).collect::<Vec<_>>();
match try!(ops::load_lockfile(&lockfile, source_id)) {
Some(r) => try!(add_lockfile_sources(&mut registry, &package, &r)),
}
let resolved = try!(resolver::resolve(package.get_package_id(),
- package.get_dependencies(),
+ dependencies.as_slice(),
&mut registry));
try!(registry.add_overrides(override_ids));
let resolved_with_overrides =
try!(resolver::resolve(package.get_package_id(),
- package.get_dependencies(),
+ dependencies.as_slice(),
&mut registry));
let req: Vec<PackageId> = resolved_with_overrides.iter().map(|r| {
use std::io::File;
use support::{ResultTest, project, execs, main_file, cargo_dir, path2url};
-use support::{COMPILING, FRESH};
+use support::{COMPILING, FRESH, RUNNING};
use support::paths::PathExt;
use hamcrest::{assert_that, existing_file};
use cargo;
p2.build();
assert_that(p.cargo_process("cargo-build"),
- execs().with_stdout(format!("{} bar v0.5.0 ({})\n\
- {} foo v0.5.0 ({})\n",
- COMPILING, p.url(),
- COMPILING, p.url())));
+ execs().with_status(101))
+})
- assert_that(&p.bin("foo"), existing_file());
+test!(cargo_compile_with_root_dev_deps_with_testing {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [project]
- assert_that(
- cargo::util::process(p.bin("foo")),
- execs().with_stdout("zoidberg\n"));
+ name = "foo"
+ version = "0.5.0"
+ authors = ["wycats@example.com"]
+
+ [dev-dependencies.bar]
+
+ version = "0.5.0"
+ path = "../bar"
+
+ [[bin]]
+ name = "foo"
+ "#)
+ .file("src/main.rs",
+ main_file(r#""{}", bar::gimme()"#, ["bar"]).as_slice());
+ let p2 = project("bar")
+ .file("Cargo.toml", r#"
+ [package]
+
+ name = "bar"
+ version = "0.5.0"
+ authors = ["wycats@example.com"]
+ "#)
+ .file("src/lib.rs", r#"
+ pub fn gimme() -> &'static str {
+ "zoidberg"
+ }
+ "#);
+
+ p2.build();
+ assert_that(p.cargo_process("cargo-test"),
+ execs().with_stdout(format!("\
+{compiling} bar v0.5.0 ({url})
+{compiling} foo v0.5.0 ({url})
+{running} target[..]test[..]foo-[..]
+
+running 0 tests
+
+test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
+
+", compiling = COMPILING, url = p.url(), running = RUNNING)));
})
test!(cargo_compile_with_transitive_dev_deps {